package ru.stepanovdn.trading.loader.entity

import jakarta.persistence.*
import java.time.LocalDateTime

@Entity
@Table(
    name = "candle",
    indexes = [Index(columnList = "id", unique = true), Index(columnList = "isin", unique = false)]
)
class Candle (

    @get:Id
    @get:GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "candle_gen")
    @get:SequenceGenerator(name = "candle_gen", sequenceName = "candle_id_seq", allocationSize = 1, schema = "public")
    @get:Column(name = "id")
    var id: Int = 0,

    @Column(name = "isin", nullable = false, updatable = false, unique = false, length = 12)
    var isin: String,

    @Column(name = "ticker", nullable = false, length = 5)
    var ticker: String,

    @Column(name = "open", scale = 9, precision = 2, nullable = false)
    var open: Float,

    @Column(name = "high", scale = 9, precision = 2, nullable = false)
    var high: Float,

    @Column(name = "low", scale = 9, precision = 2, nullable = false)
    var low: Float,

    @Column(name = "close", scale = 9, precision = 2, nullable = false)
    var close: Float,

    @Column(name = "volume", nullable = false)
    var volume: Int,

    @Column(name = "time", nullable = false)
    var time: LocalDateTime,

    @Column(name = "timeline", nullable = false)
    var timeline: LocalDateTime,

    @Column(name = "complete", nullable = false)
    var complete: Boolean

)